USE [CallCenter]
GO

/****** Object:  StoredProcedure [dbo].[sp_transfer_all_prospects]    Script Date: 06/23/2013 22:06:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_transfer_all_prospects] 
	-- Add the parameters for the stored procedure here
	@SaleID int,
	@SaleIDNew int
AS
BEGIN
	DECLARE @GID int
	WHILE (SELECT COUNT(*) FROM Guests WHERE Guests.SaleID=@SaleID) > 0
	BEGIN
		SET @GID = (SELECT TOP 1 GuestID FROM Guests WHERE Guests.SaleID=@SaleID)		
		UPDATE Guests
		SET SaleID = @SaleIDNew
		WHERE GuestID = @GID
	END
END

GO

